#include "lexer_fsm.h"
#include "common/utils.h"
#include <iostream>

int main(int argc, char const *argv[]) 
{

    if (argc < 2) 
    {
        std::cout << "Missing input file.\n";
        return 1;
    } 
    else if (argc > 2) 
    {
        std::cout << "Too many input files.\n";
        return 1;
    }
    std::string path = std::string{argv[1]};

    auto src = common::ReadFromFileAndTrim(path);
    lexer::FiniteStateMachine fsm;
    fsm.SetSrcCode(src);
    fsm.Start();
    auto res = fsm.GetTokens();
    for (const auto& wt : res) 
    {
        common::Printer(wt.type, wt.word);
    }
    return 0;
}
